package org.idea.spring.bean.aware;

import org.springframework.beans.factory.BeanNameAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author linhao
 * @Date created in 1:58 下午 2021/5/2
 */
public class Person implements BeanNameAware {

    public int id;

    private String beanName;

    @PostConstruct
    public void init(){
        System.out.println("对象开始初始化");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("对象进入销毁状态");
    }

    /**
     * BeanNameAware 回调
     * @param name
     */
    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }
}
